package com.zhtools.wx.utils;

import java.util.Date;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

/**
 * 微信工具类
 */
public final class WXUtil {
    /**
     * 获取随机字符串 Nonce Str
     *
     * @return String 随机字符串
     */
    public static String generateNonceStr() {
        return UUID.randomUUID().toString().replaceAll("-", "").substring(0, 32);
    }

    /**
     * 获取当前时间戳 单位"秒"
     * @return
     */
    public static String generateTimestamp() {
        Date date = new Date();
        long val = TimeUnit.SECONDS.convert(date.getTime(), TimeUnit.SECONDS);
        return Long.toString(val);
    }
}
